package com.gupao.gupaoeduvippattern.javaBase.thread.day01;

/**
 * @author Administrator
 * @date 2020-12-04 15:12
 */
public class ThreadDemo3 {

    public static void main(String[] args) {
        AThread aThread = new AThread();
        Thread t1 = new Thread(aThread);
        t1.start();

        AThread aThread2 = new AThread();
        Thread t2 = new Thread(aThread2);
        t2.start();

        /*BThread bThread = new BThread();
        Thread t2 = new Thread(bThread);
        t2.start();*/

    }

}

class AThread implements Runnable{

    @Override
    public void run() {
        int i = 1;
        while(i <= 10)
            System.out.println(Thread.currentThread() + "正在运行" + i++);
            System.out.println("aaaaaaa");
    }
}

class BThread implements Runnable{

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {
        int i = 1;
        while(i <= 10){
            System.out.println(Thread.currentThread() + "正在运行" + i++);
        }
    }
}
